﻿/**
 * ...
 * @author Lobanov AV.
 */
	
package
{
	import controller.StartupCommand;
	import ishwest.mioc.MiocFacade;
	import org.puremvc.as3.interfaces.IFacade;
	import org.puremvc.as3.patterns.facade.Facade;
	
	import controller.*;
	
	import flash.display.DisplayObject;
	
	public class ApplicationFacade extends Facade implements IFacade 
	{
		// Notification name constants
		public static const STARTUP:String = "startup";
		
		/****************************************************************
		 * data notification
		 */
		public static const CORE_DATA_IS_LOAD:String = "load core data is success";//NOTIFICATION!
		public static const LOAD_STATIC_DATA:String = "load static data";//NOTIFICATION!
		public static const NEWS_DATA_IS_LOAD:String = "load news data is success";//NOTIFICATION!
		
		
		/****************************************************************
		 * GUI state notification
		 */
		public static const DISPATCH_STAGE_RESIZE:String = "request stage width and height";//COMMAND!
		public static const STAGE_IS_RESIZE:String = "stage is resize";//NOTIFICATION!
		public static const CHANGE_MODULE:String = "we need load new module";//COMMAND!
			
			
		/****************************************************************
         * Singleton ApplicationFacade Factory Method
         */
		public static function getInstance():ApplicationFacade 
		{
			if (instance == null) instance = new ApplicationFacade();
			return instance as ApplicationFacade;
		}
		
		/****************************************************************
         * Register Commands with the Controller 
         */
		override protected function initializeController():void 
		{
			super.initializeController();
			
			registerCommand( STARTUP, StartupCommand );
			registerCommand( DISPATCH_STAGE_RESIZE, DispatchStageResizeCommand );
			registerCommand( LOAD_STATIC_DATA, LoadStaticDataCommand );
			registerCommand( CHANGE_MODULE, LoadModuleCommand );
		}
		
		/**
		 * enter point of application
		 * @param	root
		 */
		public function startup( root:DisplayObject ):void 
		{
			sendNotification( STARTUP, root );
		}
	}
}